# sphere mesh generation test

#!/usr/bin/env python

from scipy import *
from enthought.mayavi import mlab
import sys
sys.path.append( '../' )

from field import template_fields
from field import geometric_field
from field.topology import element_types

# sphere parameters
azimuth_divs = 5
incline_divs = 3
radius = 10.0
inclination_max = pi*3/4

eval_density = 20

# make hemi and parameters
(sphere, xparam, yparam, zparam, c) = template_fields.sphere( azimuth_divs, incline_divs, radius, inclination_max )
sphere.subfields[1].remove_element(1)
#~ sphere.remove_element(1)

# evaluate
x = sphere.evaluate_field_in_mesh( eval_density, xparam )
x = array(x).flatten()

y = sphere.evaluate_field_in_mesh( eval_density, yparam )
y = array(y).flatten()

z = sphere.evaluate_field_in_mesh( eval_density, zparam )
z = array(z).flatten()


p = mlab.points3d( x,y,z, mode = 'point', scale_factor = 0.5)
n = mlab.points3d( xparam, yparam, zparam, mode = 'sphere', scale_factor = 1.0, color = (1,0,0) )
mlab.show()
